﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.BusinessObject.Poll;

public partial class Controls_wucPoll : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();
    }

    private void LoadData()
    {
        PollEvent pollEvent = PollEvent.GetCurrentPollEvent();
        PollQuestion pollQuestion = pollEvent.Question;

        if (pollEvent != null && pollQuestion != null)
        {
            lblQuestion.Text = pollQuestion.Question;

            rblAnswers.DataSource = PollAnswer.GetAnswersForQuestion(pollQuestion);
            rblAnswers.DataBind();
        }
    }

    protected void Vote_Command(object sender, EventArgs e)
    {
        // Determine which button was clicked
        // and set the ActiveViewIndex property to
        // the view selected by the user.
        if (DevPollMultiView.ActiveViewIndex > -1 & DevPollMultiView.ActiveViewIndex < 1)
        {
            // Increment the ActiveViewIndex property 
            // by one to advance to the next view.
            DevPollMultiView.ActiveViewIndex += 1;
        }
        else if (DevPollMultiView.ActiveViewIndex == 1)
        {
            // This is the final view.
            // The user wants to save the survey results.
            // Insert code here to save survey results.
            // Disable the navigation buttons.
        }
        else
        {
            throw new Exception("An error occurred.");
        }
    }

}
